package com.icss.ah.orderDetail.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class OrderDetailService {
	
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;
	private final Logger errlog = Logger.getLogger("E");
	private final Logger infolog = Logger.getLogger("I");
	
	
	/**
	 * 获取所有订单包含商品列表
	 * @param map
	 * @return
	 */
	public List<Map<String, Object>> getOrderProductList(Map<String, String> map) {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		try {
			list = sqlSessionTemplate.selectList(
					"OrderDetailBean.getOrderProductList", map);
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("OrderDetailService|getOrderProductList", e);
		}
		return list;
	}

	/**
	 * 所有订单包含商品总数
	 * @param map
	 * @return
	 */
	public Long getOrderProductTotal(Map<String, String> map) {
		Long count = 0L;
		try {
			count = sqlSessionTemplate.selectOne("OrderDetailBean.getOrderProductTotal",map);
			infolog.info("OrderDetailService|getOrderProductTotal|count: "+count);
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("OrderDetailService|getOrderProductTotal", e);
		}
		return count;
	}

	/**
	 * 所有订单包含商品品种总数
	 * @param map
	 * @return
	 */
	public Long getOrderProductCount(Map<String, String> map) {
		Long count = 0L;
		try {
			count = sqlSessionTemplate.selectOne("OrderDetailBean.getOrderProductCount",map);
			infolog.info("OrderDetailService|getOrderProductCount|count: "+count);
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("OrderDetailService|getOrderProductCount", e);
		}
		return count;
	}
	
	

}
